|
AWT스윙GUI |
[1] |
|
등록일:2008-03-10 00:47:11 (0%) 작성자: 제목:GridBagLayout, GridBagConstraints |
|
fill
기 본적으로, 컴포넌트의 크기는 셀의 크기와 상관없이 컴포넌트의 적절한 또는 최소 크기로 설정된다. 하지만 컴포넌트가 수평, 수직 또는 둘다 표시 가능한 영ㅇ역을 채우기 위해서 컴포넌트를 늘이도록 지시하는 fill 제약조건을 사용할 수 있다.
GridBagConstraints안에는 fill값을 설정하는 데 사용되는 네 개의 상수가 정의되어 있다.
· HORIZONTAL
컴포넌트를 수평으로 확장
· VERTICAL
컴포넌트를 수직으로 확장
· BOTH
표시영역을 채우기 위해서 컴포넌트를 수평과 수직 양쪽 모두 확장
· NONE
컴포넌트가 원래의(적절한 또는 최소) 크기로 있게 한다.(기본값)
ex)
public class Test {
public static void main(String[] args) {
JFrame f = new JFrame("GridBagLayout Testing");
f.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
Container pane = f.getContentPane();
gbc.gridy = 0;
gbc.gridx = GridBagConstraints.RELATIVE;
pane.add(new JButton("This button's preferred
width is large because its text is long"),gbc);
gbc.gridy = 1;
pane.add(new JButton("2nd"),gbc);
gbc.gridy = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
pane.add(new JButton("5th"),gbc);
f.setBounds(0,0,400,300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
[출처] GridBagLayout, GridBagConstraints|작성자 가온
http://blog.naver.com/kimwj304?Redirect=Log&logNo=50021438674 |
[본문링크] GridBagLayout, GridBagConstraints
|
[1]
|
|
|
|
|
코멘트(이글의 트랙백 주소:/cafe/tb_receive.php?no=2445 |
|
|
|
|
|
|
|
|
|
Copyright byCopyright ⓒ2005, SSISO Community All Rights Reserved.
|
|
|